home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 361_01 / apo.c < prev    next >
C/C++ Source or Header  |  1991-09-18  |  2KB  |  96 lines

  1.  
  2.  
  3. /* APO  --> A "Boxed" Ask w/ Prompts & Output
  4.  *
  5.  * J.Ekwall     18 December 1989
  6.  *
  7.  * Copyrighted to the Public Domain.  Unlimited Distribution Authorized.
  8.  *
  9.  * User Assumes All Risks/Liabilities.
  10.  *
  11.  */
  12.  
  13. #include <ctype.h>
  14. #include <gadgets.h>
  15. #include <keys.h>
  16. #include <stdio.h>
  17. #include <stdek.h>
  18. #include <string.h>
  19.  
  20.  
  21. char *Documentation[] = {
  22.     "",
  23.     "Usage:",
  24.     "        APO [/option] text [title]",
  25.     "",
  26.     "Options:",
  27.     "       /I ---> Ignore Case.  (Everything is UPPERS).",
  28.     "       /N ---> Numbers Only.",
  29.     "",
  30.     "   Produces an \"Ask\" Box w/ Prompts & Seed Text.  Squirts to Stdout.",
  31.     "",
  32.     "   APO may be Piped w/o Disrupting User Input.",
  33.     "",
  34.     "Last Updated: 20 Sept 91/EK.",
  35.     "",
  36.     NULL};
  37.  
  38. char *Pop_Help[] = {
  39.     "",
  40.     " Esc ---> Cancel Input.",
  41.     "",
  42.     " F1 ----> Cheat Sheet Help.",
  43.     " F2 ----> Build Any ASCII Character.",
  44.     "",
  45.     " BS ----> Rubout Text.",
  46.     "",
  47.     " Enter -> Accept Entry & Go On.",
  48.     "",
  49.     NULL };
  50.  
  51. /* Declare ProtoTypes */
  52. void Usage(void);
  53.  
  54. main (int argc, char *argv[])
  55. {
  56.     int c, i, Flag = 0;
  57.     char *tp1, Text[80], Title[80];
  58.  
  59.  /* Set Option Flags */
  60.     while (*argv[1] IS SLASH) {
  61.        for (tp1 = argv[1] + 1; *tp1 != NULL; ) {
  62.           switch (toupper(*tp1++)) {
  63.           case  'I': Flag =  1; break;          /* CaseLess */
  64.           case  'N': Flag = -1; break;          /* Numerics */
  65.           default:
  66.              fprintf(stderr,"\nInvalid  Option [/%c].\n\n",*tp1); Usage();
  67.           }
  68.        }
  69.  
  70.     /* SHIFT <Preserve argv[0]> */
  71.        for (i = 1, --argc; i < argc + 1; i++) argv[i] = argv[i+1];
  72.     }
  73.     /* Check for OutFlow Pipe */
  74.     if (!OUTFLOW_EXISTS) Usage();
  75.  
  76.  /* Capture Prompts & Seed Text (IF Any) */
  77.     if (argc IS 1) Usage();             /* Blank Box is Illegal */
  78.     strcpy(Text,argv[1]);
  79.     if (argc > 2) {
  80.        strcpy(Title, "[ "); strcat(Title, argv[2]); strcat(Title, " ]");
  81.     } else *Title = NULL;
  82.  
  83.  /* Mainline */
  84.     if (Query(Text, Title, Flag, 0x4F, Pop_Help)) printf("%s\n", Text);
  85.     printf("%c", DOS_EOF);
  86. }
  87.  
  88. void Usage(void)
  89. {
  90.     char   **dp = Documentation;
  91.  
  92.     for ( ; *dp; dp++) fprintf(stderr,"%s\n", *dp);
  93.     exit(1);
  94. }
  95.  
  96.